package com.dingup.api.bean.requestBean.lesson;

import com.alibaba.fastjson.JSONArray;
import com.dingup.api.bean.requestBean.subject.ExamSubjectBean;
import com.dingup.api.model.lesson.LessonInfo;
import com.dingup.api.model.lesson.LessonSubjectInfo;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by wancheng on 2018/8/24.
 */
public class LessonInfoBean {

    private Integer id;
    private String lessonName;
    private String lessonCampus;
    private Integer totalClassHour;
    private String exam;
    private Double price;
    private String type;
    private String lessonInfoJson;

    public LessonInfo getLessonInfo(){
        LessonInfo lessonInfo = new LessonInfo();
        lessonInfo.setExam(this.exam);
        lessonInfo.setLessonCampus(this.lessonCampus);
        lessonInfo.setId(this.id);
        lessonInfo.setLessonName(this.lessonName);
        lessonInfo.setPrice(this.price);
        lessonInfo.setType(this.type);
        lessonInfo.setLessonClassHours(this.totalClassHour);
        if (!StringUtils.isEmpty(lessonInfoJson)){
            List<LessonSubjectInfo> subjectInfos = new ArrayList<>();
            for ( ExamSubjectBean e: JSONArray.parseArray(lessonInfoJson,ExamSubjectBean.class)) {
                e.setLessonId(this.id);
                subjectInfos.add(e.asLessonSubjectInfo());
            }
            lessonInfo.setSubjectInfos(subjectInfos);
        }
        return lessonInfo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLessonName() {
        return lessonName;
    }

    public void setLessonName(String lessonName) {
        this.lessonName = lessonName;
    }

    public String getLessonCampus() {
        return lessonCampus;
    }

    public void setLessonCampus(String lessonCampus) {
        this.lessonCampus = lessonCampus;
    }

    public String getExam() {
        return exam;
    }

    public void setExam(String exam) {
        this.exam = exam;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getLessonInfoJson() {
        return lessonInfoJson;
    }

    public void setLessonInfoJson(String lessonInfoJson) {
        this.lessonInfoJson = lessonInfoJson;
    }

    public Integer getTotalClassHour() {
        return totalClassHour;
    }

    public void setTotalClassHour(Integer totalClassHour) {
        this.totalClassHour = totalClassHour;
    }
}
